<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">      <!--声明Thymeleaf命名空间-->
<head>
    <title>菜单配置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="/css/bootstrap.min.css" ></link>
</head>
<body>

<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <a class="navbar-brand" href="/index.html">系统后台管理</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav ">
                <li><a href="/admin/role.html">角色管理</a></li>
                <li ><a href="/admin/menu.html">菜单管理</a></li>
                <li class="active"><a href="/admin/apis.html">API管理</a></li>
                <li><a href="/admin/cache.html">缓存管理</a></li>
            </ul>

        </div><!-- /.navbar-collapse -->

    </div><!-- /.container-fluid -->
</nav>
<div class="container-fluid">

<ol class="breadcrumb">
    <li><a href="#">首页</a></li>
    <li><a href="#">权限管理</a></li>
    <li class="active">API管理</li>
</ol>
    <div class="panel panel-default">
        <div class="panel-body">
            <h1>API管理</h1>
            <a class="btn btn-default" id="tb"style="margin-bottom: 10px;" role="button">同步</a>
            <table id="table" class="table table-bordered table-striped">
                <tr>
                    <th>tag</th>
                    <th>备注</th>
                    <th>HttpMethod</th>
                    <th>请求路径</th>
                    <th>方法名称</th>

                </tr>
            </table>
        </div>
    </div>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="/js/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="/js/bootstrap.min.js"></script>
<script src="/js/auth.js"></script>
<script>
    $.ajax({
        type: 'GET',
        url: '/v1/apis/list',
        dataType: 'json',
        success:function(data){
            if(data!=null&&data.data!=null&&data.code==200){
                var dataList=data.data;
                var html=$("#table").html();
                var tr="";
                for(var i=0;i<dataList.length;i++){
                    tr+='<tr>';
                    tr+='<td>'+dataList[i].tag;
                    tr+='</td>';
                    tr+='<td>'+dataList[i].summary;
                    tr+='</td>';
                    tr+='<td>'+dataList[i].method;
                    tr+='</td>';
                    tr+='<td>'+dataList[i].path;
                    tr+='</td>';
                    tr+='<td>'+dataList[i].operationId;
                    tr+='</td>';


                    tr+='</tr>';

                }
                html+=tr;
                $("#table").html(html);

            }

        }
    });
    $("#tb").click(function(){
        $.ajax({
            type: 'GET',
            url: '/v1/apis/updateApi',
            dataType: 'json',
            success:function(data){
                if(data!=null&&data.code==200){
                    alert("更新成功,刷新界面");
                    location.reload();
                }
            },
            error:function(jqXHR, textStatus, errorThrown){
                var json = JSON.parse(jqXHR.responseText);
                alert(json.message);
            }
        });
    });
</script>
</body>
</html>